package com.kai.module_cartoon.cart

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.kai.base.base.basic.extras.load
import com.kai.base.utils.IStringUtils
import com.kai.module_cartoon.R
import com.kai.module_cartoon.databinding.CartoonImageItemBinding
import com.youth.banner.adapter.BannerAdapter

/**
 * @Author: 小强同学
 * @Date:  2021/3/19 17:07
 * @Description:  Banner 适配器
 */
class CartoonBanner(list: MutableList<CartoonBean.BannerData>) : BannerAdapter<CartoonBean.BannerData,ImageViewPageHolder<CartoonImageItemBinding>>(list) {

    override fun onBindView(holder: ImageViewPageHolder<CartoonImageItemBinding>?, data: CartoonBean.BannerData?, position: Int, size: Int) {
        holder?.viewBinding?.apply {
            image.load(IStringUtils.getString(data?.imageUrl))
            bannerTitle.text = IStringUtils.getString(data?.imageMsg)
        }

    }

    override fun onCreateHolder(parent: ViewGroup?, viewType: Int): ImageViewPageHolder<CartoonImageItemBinding> {
        val itemView: View = LayoutInflater.from(parent!!.context).inflate(R.layout.cartoon_image_item, parent, false)
        return ImageViewPageHolder(CartoonImageItemBinding.bind(itemView))
    }
}